#!/bin/ksh
# IBM_PROLOG_BEGIN_TAG 
# This is an automatically generated prolog. 
#  
#  
#  
# Licensed Materials - Property of IBM 
#  
# (C) COPYRIGHT International Business Machines Corp. 2001,2002 
# All Rights Reserved 
#  
# US Government Users Restricted Rights - Use, duplication or 
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp. 
#  
# IBM_PROLOG_END_TAG 

# "@(#)81   1.2   src/rsct/rm/ER/ewallevent, ERrm, rsct_rpyxh, rpyxht1f3 7/28/02 15:13:26";

#####################################################################
#
# Name:    wallevent
#
# Purpose: Broadcast a message to the console to notify all the 
#          logged-in of an event or a rearm event
#
# Inputs:  None
#
#####################################################################

# main()

PERL=/usr/sbin/rsct/perl5/bin/perl

while getopts ":h" opt
do
  case $opt in

    h ) print "Usage: `basename $0` [-h] "
        exit 0;;

    ? ) print "Usage: `basename $0` [-h] "
        exit 3;;
  esac
done

# convert time string
seconds=${ERRM_TIME%,*}

EventTime=$(LC_ALL=C seconds=$seconds $PERL -e \
'
use POSIX qw(strftime);
print strftime("%A %D %T", localtime($ENV{seconds}) );  

'
)

# Convert Seveirty 
case $ERRM_COND_SEVERITYID in

    0 ) COND_SEVERITY=Informational;;
    1 ) COND_SEVERITY=Warning;;
    2 ) COND_SEVERITY=Critical;;

esac

# Convert EventType
case $ERRM_TYPEID in

    0 ) TYPE=Event;;
    1 ) TYPE=RearmEvent;;

esac


wall "$COND_SEVERITY $TYPE occurred for the condition $ERRM_COND_NAME on the resource $ERRM_RSRC_NAME of the resource class $ERRM_RSRC_CLASS_PNAME at $EventTime. The resource was monitored on $ERRM_NODE_NAME and resided on $ERRM_NODE_NAMELIST." 


